<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
<script type="text/javascript" src="js/JnPakg.js"></script>
<script type="text/javascript">
(function(){
	dw("08_prototype的继承[2].html");
})();


//实现继承有两种方法,一种是构造继承法,一种是原型继承法
var A = function(_size){
	dw("A的构造方法被执行了")
	var n = _size;
	this.size = function(){return n;}
}
A.x = "x";
A.y = "y";
A.prototype.maxSize = function(){return "max : "+this.size();}
A.prototype.x = 5;
var a = new A(5);
dw("a.size()" + a.size());
dw("a.maxSize()" + a.maxSize());
dw("a.x : " + a.x);
dw("a.y : " + a.y);
dw("A.x : " + A.x);
dw("A.y : " + A.y);
dw.dl();

/**实例继承.[有缺陷]
**/
var B1 = function(_size){
	var ins = new A(_size);
	return ins;
}

var b1 = new B1();
dw(b1.x);
dw(b1.y);
dw("B1.maxSize()" + b1.maxSize());//当[B1.prototype = A.prototype]执行会出错
if(b1 instanceof B1){
	dw("b1是B1")
}else{
	dw("否")
}
if(b1 instanceof A){
	dw("b1是A")
}else{
	dw("否")
}
dw.dl();




</script>
</html>